import java.util.*;
import java.util.concurrent.CountDownLatch;

/**
 * Created by liuyf on 2018/3/22.
 */
import java.util.Scanner;
import java.util.regex.Pattern;


public class Pool {

    private static final String carSplit = ";";
    private static final String timeSplit = ",";
    private static final String regress = "(\\d{1,2},\\d{1,2};)*\\d{1,2},\\d{1,2}$";

    public static void main(String[] args) {
        String inString = null;
        // 数据输入
        Scanner in = new Scanner(System.in);
        inString = in.nextLine();
        //字符串数组格式校验
        Pattern pat = Pattern.compile(regress);
        if (inString == null || inString.trim().equals("") || !pat.matcher(inString).matches()) {
            System.out.println("输入错误!");
            return;
        }
        Pool sol = new Pool();
        int countCars = sol.countCars(sol.convertToArray(inString));
        System.out.println(countCars);
    }

    //输入字符串转数组
    public int[][] convertToArray(String str) {
        String[] strArray = str.split(carSplit);
        int row = strArray.length;
        int col = 2;
        // 字符转数组判断
        int[][] carArray = new int[row][col];
        int start, end;
        for (int i = 0; i < row; i++) {
            start = Integer.parseInt(strArray[i].split(timeSplit)[0]);
            end = Integer.parseInt(strArray[i].split(timeSplit)[1]);
            if (start > end) {
                continue;
            }
            carArray[i][0] = start;
            carArray[i][1] = end;
        }
        return carArray;
    }

    //核心算法实现
    public int countCars(int[][] Interval) {
        if (Interval == null || Interval.length == 0) return 0;
        Arrays.sort(Interval, Comparator.comparingInt(o -> o[0]));
        // 用堆来管理房间的结束时间
        PriorityQueue<Integer> endTimes = new PriorityQueue<>();
        endTimes.offer(Interval[0][1]);
        for (int i = 1; i < Interval.length; i++) {
            // 如果当前时间段的开始时间大于最早结束的时间，则可以更新这个最早的结束时间为当前时间段的结束时间，如果小于的话，就加入一个新的结束时间，表示新的房间
            if (Interval[i][0] >= endTimes.peek()) {
                endTimes.poll();
            }
            endTimes.offer(Interval[i][1]);
        }
        // 有多少结束时间就有多少房间
        return endTimes.size(); // 返回计算结果
    }
}